package com.codedancer.campus.manager.api.commodity;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.codedancer.campus.common.anno.InterfacePermission;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import com.codedancer.campus.manager.api.commodity.ro.CommodityExamineRecordPageSearchRo;
import com.codedancer.campus.manager.service.ICommodityExamineRecordService;
import com.codedancer.campus.manager.service.bo.commodity.CommodityExamineRecordPageSearchBo;
import com.codedancer.campus.manager.service.vo.commodity.CommodityExamineRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/commodity-examine-record")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "商品审核记录Api", description = "商品审核记录Api", tags = "商品审核记录Api")
public class CommodityExamineRecordApi extends BaseApi {

    @Autowired
    private ICommodityExamineRecordService commodityExamineRecordService;

    @GetMapping("/page/{commodityUuid}")
    @ApiOperation("分页查询商品审核记录")
    @InterfacePermission(encodes = {"superAdmin","commodityAdmin"})
    public ApiResponse<IPage<CommodityExamineRecordVo>> page(
        @PathVariable(value = "commodityUuid", required = true) @ApiParam(value = "商品uuid", required = true) String commodityUuid,
        @ApiParam(value = "商品审核记录分页查询Ro", required = false) CommodityExamineRecordPageSearchRo commodityExamineRecordPageSearchRo) {
        CommodityExamineRecordPageSearchBo commodityExamineRecordPageSearchBo = BeanUtil
            .copyProperties(commodityExamineRecordPageSearchRo,
                CommodityExamineRecordPageSearchBo.class);
        commodityExamineRecordPageSearchBo.setCommodityUuid(commodityUuid);
        return success(commodityExamineRecordService.page(commodityExamineRecordPageSearchBo));
    }
}
